<?pyhp
# vim: set filetype=python

import os, sys
from liwe import liwe

os.environ [ 'PYTHON_EGG_CACHE' ] = '/tmp'

#print os.getcwd ()
#print pyhp.env

cfg_path = os.path.join ( pyhp.env [ "DOCUMENT_ROOT" ], "site", "liwe.cfg" )

l = liwe ( pyhp, cfg_path )
#print dir ( l )

#rem = """
pyhp.set_header ( "Content-Type", "text/csv" )
pyhp.set_header ( "Pragma", "no-cache" )
pyhp.set_header ( "Content-Disposition", 'attachment; filename="banner_stats.csv"' )

import csv
import StringIO

from banner_class import Banner

b = Banner ( l )
res = b.get_stats ( )

out = StringIO.StringIO ()
dw = csv.DictWriter ( out, ( "created", "id_obj", "container", "grp", "url_click", "event" ), extrasaction = 'ignore' )

dw.writerows ( res )

print out.getvalue ()

#"""
?>
